package com.yeeverse.sdk.api;

import com.yeeverse.sdk.exception.SdkException;

/**
 * sdk环境变量
 */
public class SdkContext {

    private static SdkContext SDK_CONTEXT;
    /**
     * 应用id
     */
    private String appId;
    /**
     * 商户私钥
     */
    private String privateKey;
    /**
     * yeeverse公钥
     */
    private String publictKey;
    /**
     * yeeverse基础路径
     */
    private String baseUrl;
    /**
     * Aes秘钥
     */
    private String aesKey;

    public SdkContext(String appId, String privateKey, String publictKey, String baseUrl) {
        this.appId = appId;
        this.privateKey = privateKey;
        this.publictKey = publictKey;
        this.baseUrl = baseUrl;
        SDK_CONTEXT = this;
    }

    public static SdkContext getCurrentSdk() {
        if (null == SDK_CONTEXT) {
            throw new SdkException("当前sdk环境变量未初始化");
        }
        return SDK_CONTEXT;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public String getPublictKey() {
        return publictKey;
    }

    public void setPublictKey(String publictKey) {
        this.publictKey = publictKey;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public void destory() {
        SDK_CONTEXT = null;
    }

    public String getAesKey() {
        return aesKey;
    }

    public void setAesKey(String aesKey) {
        this.aesKey = aesKey;
    }
}
